package com.wuyou.designPatterns.factory.abstractfactory.tablefactory;

import com.wuyou.designPatterns.factory.abstractfactory.factory.Item;
import com.wuyou.designPatterns.factory.abstractfactory.factory.Page;

import java.util.Iterator;

public class TablePage extends Page {
    public TablePage(String title, String author) {
        super(title, author);
    }

    @Override
    public String makeHTML() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("<html>").append("<head>").append("<title>").append(title).append("</title>").append("</head>\n");
        buffer.append("<body>\n");
        buffer.append("<h1>").append(title).append("</h1>\n");
        buffer.append("<table ").append("width=\"80%\"").append("border=\"3\"").append(">\n");
        Iterator<Item> iterator = content.iterator();
        while (iterator.hasNext()){
            buffer.append(iterator.next().makeHTML());
        }
        buffer.append("</table>\n").append("<hr>").append("<address>").append(author).append("</address>");
        buffer.append("</body>\n").append("</html>\n");
        return buffer.toString();
    }
}
